<template>
    <div class="enterpriseWithdrawalApplication-acceptance-registration-increase">
        <!-- 新增弹窗 -->
        <a-modal
        class="acceptance-modal"
        :visible="visibleShow" 
        :title="parameterData.sqsxid?'办理':'新增'"
        :maskClosable="false"
        :closable="false"
        :destroyOnClose="true"
        :forceRender="true"
        :footer="null"
        width="100%"
        wrapClassName="full-modal"
        >
            <a-spin size="large" :spinning="modalSpinningPrice" :key="spinningKey">
                <div style="width: 100%; background-color: #fff;position: fixed; top: 0;z-index: 99;left:0;padding: 10px 10px 10px 24px; display: flex;">
                    <div>
                        <a-button class="blue-btn" type="primary" @click="returnClick()">返回</a-button>
                        <a-button style="margin-left: 10px;" class="blue-btn" type="primary" @click="refreshClick()">刷新</a-button>
                    </div>
                    <div style="margin-left: 50px;">
                        <a-button class="blue-btn" type="primary" @click="returnGovernmentServices('qycjsqlcsubmitFlow')">办理</a-button>
                        <!-- <a-button style="margin-left: 10px;" class="blue-btn" type="primary" @click="recordClick()">查看撤件申请记录</a-button> -->
                    </div>
                </div>
                <div style="width: 100%;height: 25px;"></div>
                <a-tabs v-model:activeKey="matterActiveKey" @change="matterChange" class="matter-handle-tabs">
                    <a-tab-pane key="事项办理" tab="事项办理"></a-tab-pane>
                    <a-tab-pane key="事项信息" tab="事项信息"></a-tab-pane>
                </a-tabs>
                <div v-show="matterActiveKey == '事项办理'" style="margin-top: 80px">
                    <a-form
                    layout="horizontal" 
                    class="withdrawal-modal-from" >
                        <div class="withdrawal-modal-item">
                            <a-form-item label="撤件申请时间">
                                <a-input v-model:value="parameterData.fcjsqsj" disabled style="background-color: #FFF;color: rgba(0, 0, 0, 0.65);"/>
                            </a-form-item>
                            <a-form-item label="撤件意见提交时间">
                                <a-input v-model:value="parameterData.fcjyjsj" disabled style="background-color: #FFF;color: rgba(0, 0, 0, 0.65);"/>
                            </a-form-item>
                            <a-form-item label="撤件结果时间">
                                <a-input v-model:value="parameterData.fcjjgsj" disabled style="background-color: #FFF;color: rgba(0, 0, 0, 0.65);"/>
                            </a-form-item>
                        </div>
                        <a-form-item label="撤件申请原因">
                            <a-textarea readOnly v-model:value="parameterData.fcjsqyy" :autosize="{ minRows: 5, maxRows: 10000 }"/>
                        </a-form-item>
                        <a-form-item label="撤件结果">
                            <a-textarea readOnly v-model:value="parameterData.fcjjg" :autosize="{ minRows: 5, maxRows: 10000 }"/>
                        </a-form-item>
                        
                        <a-form-item label="撤件意见">
                            <a-textarea readOnly v-model:value="parameterData.fcjyj" :autosize="{ minRows: 5, maxRows: 10000 }"/>
                        </a-form-item>
                        <applicationRecord ref="applicationRecordRef"/>
                    </a-form>
                </div>
                <eventSet
                 v-show="matterActiveKey == '事项信息'"
                 :key="eventSetKey" 
                 ref="eventSetRef" 
                 :parameter="parameterData" 
                 @successReturn="successReturn" 
                 @updatedSuccess="updatedSuccess"
                 @cancelLoadingTrue="cancelLoadingTrue"
                 @cancelLoadingFalse="cancelLoadingFalse"
                 />
            </a-spin>
            <processingConditionsAll ref="processingConditionsAllRef" :processingData="processingData" @interfaceSuccessful="interfaceSuccessful"></processingConditionsAll>
            <supplementaryRectification ref="supplementaryRectificationRef" @rectificationSuccess="rectificationSuccess"/>
            
        </a-modal>
    </div>
</template>
<script>

import {addSqsxBasicServe,innerChangeFlowJob} from './service/index'
import compSelector from '@/components/compSelector/compSelector'
import eventSet from './eventSet.vue'
import applicationRecord from './applicationRecord.vue'
export default {
    components:{
        compSelector,
        eventSet,
        applicationRecord,
    },
    props:{
        addEditParameter:{
            type:[Array,Object],
            default: () => {},
            required:false
        }
    },
    data(){
        return{
            matterActiveKey:'事项办理',
            processingData:{},
            typeSelect:'Select',
            visibleShow:false,
            confirmLoading:false,
            formState:{ksfl:''},
            formRequer:'',
            spinningKey:null,
            submittedSuccessfully:false,
            parameterData:{},
            eventSetKey:null,
        }
    },
    computed: {
        modalSpinningPrice(){
            return this.$store.state.permission.modalSpinningPrice
        },
    },
    watch:{
        addEditParameter: {
            handler (newval, oldVal) {
                this.cancelLoading()
                //console.log('获取到了什么',newval)
                this.parameterData = newval
                this.formState.ksfl = ''
                this.$refs.applicationRecordRef.getData(this.addEditParameter)
                // if(!newval.sqsxid){
                //     addSqsxBasicServe().then(res=>{
                //         //console.log(res)
                //         //console.log('有进来这里吗？',res)
                //         if(res.code == 200){
                //             this.parameterData.sqsxid = res.result.sqsx.id
                //             this.parameterData.jobid = res.result.job.id
                //             this.parameterData.nextNode  = res.result.nextNode
                //             this.parameterData.nextNodeDbrList = res.result.nextNodeDbrList
                //         }
                //     })
                // }
            },
            deep: true
        },
        
    },
    mounted(){
    },
    methods:{
        matterChange(){},
        getData(val){
            this.$refs.eventSetRef.getDatas(val)
            
            //console.log(val,88888888888)
            // if(!val.sqsxid){
            //     addSqsxBasicServe().then(res=>{
            //         //console.log(res)
            //         //console.log('有进来这里吗？',res)
            //         if(res.code == 200){
            //             this.parameterData.sqsxid = res.result.sqsx.id
            //             this.parameterData.jobid = res.result.job.id
            //             this.parameterData.nextNode  = res.result.nextNode
            //             this.parameterData.nextNodeDbrList = res.result.nextNodeDbrList
            //             val.sqsxid = res.result.sqsx.id
            //             val.jobid = res.result.job.id
            //             val.nextNode = res.result.nextNode
            //             val.nextNodeDbrList = res.result.nextNodeDbrList
            //             this.$nextTick(()=>{
            //                 this.$refs.eventSetRef.getDatas(val)
            //             })
            //         }
            //     })
            // }else{
            //     this.$nextTick(()=>{
            //         this.$refs.eventSetRef.getDatas(val)
            //     })
            // }
            
        },
        cancelFalse(){
            this.cancelLoading()
        },
        cancelLoadingTrue(){
            this.$store.dispatch('UpdateSpinningPrice', {key:'true',stateKey:'modalSpinningPrice'})
        },
        cancelLoadingFalse(){
            this.$store.dispatch('UpdateSpinningPrice', {key:false,stateKey:'modalSpinningPrice'})
        },
        updatedSuccess(){
            this.cancelLoading()
        },
        cancelLoading(){
            //console.log('我再刷新')
            this.$store.dispatch('UpdateSpinningPrice', {key:true,stateKey:'modalSpinningPrice'})
        },
        returnClick(){//返回
            this.visibleShow = false
        },
        refreshClick(){
            this.$emit('reviseClick',this.addEditParameter)
            this.spinningKey = Date.now()
            this.eventSetKey = Date.now()
            this.cancelLoading()
        },
        transferClick(){//转办
            var that = this
            if(this.formState.ksfl){
                this.$confirm({
                    title:'您确认要转办吗？',
                    // icon: createVNode(ExclamationCircleOutlined),
                    onOk() {
                        innerChangeFlowJob({jobid:that.parameterData.jobid,ksfl:that.formState.ksfl}).then(res=>{
                            if(res.code == 200){
                                that.$store.dispatch('UpdateSpinningPrice', 
                                {key:true,stateKey:'modalSpinningPrice'}).then(() => {
                                    that.successReturn(false)
                                    that.$message.success(res.message)
                                })
                                
                            }else{
                                that.$store.dispatch('UpdateSpinningPrice', {key:false,stateKey:'modalSpinningPrice'})
                                that.$message.warning(res.message)
                            }
                        })
                    },
                    
                });
            }else{
                this.$message.warning('请选择转办科室')
            }
            
        },
        preserveClick(){//保存
            // this.$store.dispatch('UpdateSpinningPrice', {key:'true',stateKey:'modalSpinningPrice'})
            this.$refs.dealWithRef.handlePreserve()
        },
        submitClick(){//提交
            // this.$store.dispatch('UpdateSpinningPrice', {key:'true',stateKey:'modalSpinningPrice'})
            this.$refs.dealWithRef.shandleSubmit()
        },
        successReturn(val){
            this.visibleShow = val
            this.$emit('successReturn')
        },
        interfaceSuccessful(val){
            this.successReturn(val)
        },
        rectificationSuccess(){
            this.successReturn(false)
        },
        linkHandling(val){
            //console.log(this.addEditParameter)
            let result = this.$refs.eventSetRef.$refs.dealWithRef.shandleSubmit()
            if(result){
                this.$refs.processingConditionsAllRef.processingConditionsVisible = true
                let data = {
                    interface:val,
                    sqsxid:this.addEditParameter.sqsxid,
                    nextNodeDbrList:this.addEditParameter.nextNodeDbrList,
                    nextNode:this.addEditParameter.nextNode,
                    jobid:this.addEditParameter.jobid,
                    headerLeftTitle:'办理',
                    headerCenterTitle:'药品生产查验--任务受理',
                }
                this.processingData = data
                this.$refs.processingConditionsAllRef.getData(data)
                
            }
        },
        departmentTransfer(val){
            this.$refs.eventSetRef.$refs.dealWithRef.handlePreserve()
            this.$refs.processingConditionsAllRef.processingConditionsVisible = true
            let data = {
                interface:val,
                sqsxid:this.addEditParameter.sqsxid,
                jobid:this.addEditParameter.jobid,
                isBlyj:false,
                isZbxx:true,
                isXyb:false,
                headerLeftTitle:'转办',
                headerCenterTitle:'药品生产查验--任务受理',
            }
            this.processingData = data
            this.$refs.processingConditionsAllRef.getData(data)
        },
        returnGovernmentServices(val){
            this.$refs.supplementaryRectificationRef.visible = true
            this.$refs.supplementaryRectificationRef.getData(
                {interfaceValue:val,modalTitle:'撤件申请',opinionName:'审评中心回复意见',
                isTextMessage:false,sqsxid:this.addEditParameter.sqsxid,isTime:false,jobid:this.addEditParameter.jobid},
                {opinion:'opinion'}
            )
        },
        recordClick(){
            this.$refs.applicationRecordRef.getData(this.addEditParameter)
            this.$refs.applicationRecordRef.visible = true
        },
    }

}

</script>
<style lang="less">
/* .ant-form-item-label{
    font-weight: 600;
} */
.enterpriseWithdrawalApplication-acceptance-registration-increase{
    .ant-modal-title{
        font-weight: 600;
    }
    .ant-modal-header{
        background: #5ca3e5;
    }
    .ant-modal-footer .ant-btn-primary{
        border: 1px solid #5ca3e5 !important;
        background-color: #5ca3e5 !important;
        color: #fff !important;
    }
    .acceptance-modal .ant-modal-header{
        display: none !important;
    }
    .acceptance-modal .ant-modal-footer{
        display: none !important;
    }
    .acceptance-modal .ant-modal-content{
        height: 100vh;
        overflow: auto;
    }
    
    
}
.withdrawal-modal-from{
    display: flex;
    flex-direction: column;
    .withdrawal-modal-item{
        width: 100%;
        display: flex;
    }
    .ant-form-item{
        // width: 50%;
        flex: 1;
        display: flex;
        align-items: flex-start;
        .ant-form-item-label{
            width: 150px;
        }
        .ant-form-item-control-wrapper{
            flex: 1;
        }
    }
    
}
.full-modal {
    .ant-modal {
        max-width: 100%;
        top: 0;
        padding-bottom: 0;
        margin: 0;
    }
    .ant-modal-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        height: calc(100vh);
        background-color: #fff;
    }
    .ant-modal-body {
        flex: 1;
        background-color: #fff;
    }
}
</style>